package com.fph.design.strore;

import com.fph.design.strore.impl.CardCommodityService;
import com.fph.design.strore.impl.CouponCommodityService;
import com.fph.design.strore.impl.GoodsCommodityService;

/**
 * 创建商店工厂类
 * @ClassName StoreFactory
 * @Description TODO
 * @Author fph
 * @Date 2024-07-09 15:35
 **/
public class StoreFactory {

    public ICommodity getCommodityService(Integer commodityType)
    {
        if(null != commodityType){
            switch (commodityType)
            {
                case 1:
                    return new CouponCommodityService();
                case 2:
                    return new GoodsCommodityService();
                case 3:
                    return new CardCommodityService();
                default:
                    throw new RuntimeException("不存在的商品类型");
            }
        }
        {
            throw new RuntimeException("商品类型不能为空");
        }
    }
}

